import {Injectable} from '@angular/core';
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';
import {environment} from 'src/environments/environment';
import {Observable} from "rxjs";

@Injectable({providedIn: 'root'})
export class BaseInterceptor implements HttpInterceptor {
  private baseUrl: string = environment.BASE_URL;

  intercept(req: HttpRequest<any>,
            next: HttpHandler): Observable<HttpEvent<any>> {
    let netReq = req.clone({
      url: `${this.baseUrl}${req.url}`
    })
    return next.handle(netReq)
  }

  constructor() {

  }
}
